package com.one.blocks.rbac.util;

import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;

/**
 * @author linfuxin Created on 2022-08-29 14:40:42
 */
@UtilityClass
public class SqlFormat {

    public static String format(String sql) {
        String[] strArray = sql.split("VALUES ");
        String[] strArray1 = strArray[1].split("\\),");
        return strArray[0] + "VALUES " + System.lineSeparator()
                + StringUtils.join(strArray1, ")," + System.lineSeparator());
    }

    public static void main(String[] args) {
        String[] sqlArray = new String[]{
                "INSERT INTO `sys_tenant` VALUES (1,'SaaS平台',1,1,'2022-04-29 15:47:01',NULL,NULL),(10,'微信公共租户',1,1,'2022-08-29 10:40:45',NULL,NULL);",
                "INSERT INTO `sys_user` VALUES (1,1,'AvicsCloud管理员',NULL,'13333333333',0,1,'2022-04-29',1,'2022-04-29 15:47:01',NULL,NULL),(10,10,'微信管理员',NULL,NULL,1,1,NULL,1,'2022-08-29 10:40:45',NULL,NULL);",
                "INSERT INTO `sys_user_account` VALUES (1,1,1,1,1,'2022-04-29 15:47:01'),(2,10,10,10,1,'2022-04-29 15:47:01');",
                "INSERT INTO `sys_user_role` VALUES (1,1,1,1,1,'2022-04-29 15:47:01'),(2,10,10,10,1,'2022-04-29 15:47:01');",
        };
        for (String s : sqlArray) {
            System.out.println(format(s));
            System.out.println();
        }
    }
}
